package com.controller;

import com.service.AddressService;
import com.service.OrdersService;
import com.service.ShangpinxinxiService;
import com.service.YonghuService;
import com.tools.CommonResult;
import com.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/analysis")
@Api(tags = "数据分析模块")
@CrossOrigin
public class AnalysisController {

    @Resource
    private OrdersService ordersService;
    @Resource
    private ShangpinxinxiService shangpinxinxiService;
    @Resource
    private YonghuService yonghuService;
    @Resource
    private AddressService addressService;

    @ApiOperation("热销商品统计")
    @GetMapping("/goodSale")
    public CommonResult getGoodSale(){
        return CommonResult.success(ordersService.getGoodSale());
    }

    @ApiOperation("热销省份统计")
    @GetMapping("/ProvinceSale")
    public CommonResult getProvinceSale(){
        return CommonResult.success(shangpinxinxiService.getProvinceSale());
    }

    @ApiOperation("交易金额统计")
    @GetMapping("/MoneySale")
    public CommonResult getMoneySale(){
        return CommonResult.success(ordersService.getMoneySale());
    }

    @ApiOperation("产地商品统计")
    @GetMapping("/ChandiCount")
    public CommonResult getChandiCount(){
        return CommonResult.success(shangpinxinxiService.getChandiCount());
    }

    @ApiOperation("用户男女比例统计")
    @GetMapping("/SexCount")
    public CommonResult getSexCount(){
        return CommonResult.success(yonghuService.getSexCount());
    }

    @ApiOperation("顾客所在省份统计")
    @GetMapping("/ProvinceUser")
    public CommonResult getProvinceUser(){
        return CommonResult.success(addressService.getProvinceUser());
    }

    @ApiOperation("商品分类统计")
    @GetMapping("/CategoryCount")
    public CommonResult getCategoryCount(){
        return CommonResult.success(shangpinxinxiService.getCategoryCount());
    }

    @ApiOperation("本月营业额统计")
    @GetMapping("/MonthSale")
    public CommonResult getMonthSale(){
        return CommonResult.success(ordersService.getMonthSale());
    }

    @ApiOperation("点击量统计")
    @GetMapping("/ClickNum")
    public CommonResult getClickNum(){
        return CommonResult.success(shangpinxinxiService.getClickNum());
    }
}
